﻿#region 程序集引用
using System;
using System.Security.Cryptography;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Web;
using System.Net;
#endregion

#region 版权注释
/*===========================================================================
// Copyright (C) 2017 Zhang.cn，并保留所有 
// 作者：吴岸标 QQ:405403610
// 创建日期：2017-09-03
// 功能描述：页面请求
===========================================================================*/
#endregion

namespace Zhang
{
    namespace Utils
    {
        /// <summary>
        /// 页面请求
        /// </summary>
        public class Request
        {

            /// <summary>
            /// 获取支付宝POST过来通知消息，并以“参数名=参数值”的形式组成数组
            /// </summary>
            /// <returns>request回来的信息组成的数组</returns>
            public static SortedDictionary<string, string> GetPost()
            {
                int i;
                SortedDictionary<string, string> param;
                NameValueCollection nvCollect;

                param = new SortedDictionary<string, string>();
                nvCollect = HttpContext.Current.Request.Form;

                for (i = 0; i < nvCollect.AllKeys.Length; i++)
                {
                    param.Add(nvCollect.AllKeys[i], HttpContext.Current.Request.Form[nvCollect.AllKeys[i]]);
                }

                return param;
            }

            /// <summary>
            /// 执行远程页面，返回字符串内容
            /// </summary>
            /// <param name="url"></param>
            /// <returns></returns>
            public static string DownLoad(string url)
            {
                string result = string.Empty;

                try
                {
                    using (WebClient wClient = new WebClient())
                    {
                       result = wClient.DownloadString(url);
                    }
                }
                catch { }

                return result;
            }

        }

    }
}